/**
 * Project Name:JavaBaseReview
 * Package Name:com.xuwei.base.enumeration
 * author:David
 * Date:2016年6月7日上午8:44:52
 * Copyright (c) 2016, xw123box@126.com All Rights Reserved.
 *
 */
package com.xuwei.base.enumeration;

/**
 * 普通类模拟实现枚举功能1
 * @author David
 * @since 2016年6月7日 上午8:44:52
 * @version 
 * @since JDK 1.6
 */
public class Demo1 {
	
	public static void main(String[] args) {
		Student student = new Student();
		student.setName("Bob");
		student.setGrade("E");//运行时报错
		
	}

}

class Student{
	private String name;
	/**成绩，只能是ABCD*/
	private String grade;
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getGrade() {
		return grade;
	}
	public void setGrade(String grade) {
		if(!grade.matches("[ABCD]")){
			throw new RuntimeException("非法数值！");
		}
		this.grade = grade;
	}
	
}
